package com.jewelry.web.action;

import java.util.List;

import com.jewelry.service.IConfigAttrService;
import com.jewelry.service.IConfigurationService;
import com.jewelry.vo.ConfigAttrVO;
import com.jewelry.vo.ConfigurationVO;

public class ConfigAction extends HttpAction {

	private static final long serialVersionUID = -6960830578572726600L;
	
	private IConfigurationService configurationService;
	
	private IConfigAttrService configAttrService;
	
	//配置项的数量
	private int configCount = 0;
	
	private ConfigurationVO configurationVO;
	
	private List<ConfigurationVO> configurationList;
	
	private List<ConfigAttrVO> configAttrList;
	
	private List<ConfigurationVO> allConfigurationList;
	
	public List<ConfigurationVO> getAllConfigurationList() {
		return allConfigurationList;
	}

	public void setAllConfigurationList(List<ConfigurationVO> allConfigurationList) {
		this.allConfigurationList = allConfigurationList;
	}

	private ConfigAttrVO configAttrVO;

	public ConfigAttrVO getConfigAttrVO() {
		return configAttrVO;
	}

	public void setConfigAttrVO(ConfigAttrVO configAttrVO) {
		this.configAttrVO = configAttrVO;
	}

	public List<ConfigAttrVO> getConfigAttrList() {
		return configAttrList;
	}

	public void setConfigAttrList(List<ConfigAttrVO> configAttrList) {
		this.configAttrList = configAttrList;
	}

	public List<ConfigurationVO> getConfigurationList() {
		return configurationList;
	}

	public void setConfigurationList(List<ConfigurationVO> configurationList) {
		this.configurationList = configurationList;
	}

	public ConfigurationVO getConfigurationVO() {
		return configurationVO;
	}

	public void setConfigurationVO(ConfigurationVO configurationVO) {
		this.configurationVO = configurationVO;
	}

	public int getConfigCount() {
		return configCount;
	}

	public void setConfigCount(int configCount) {
		this.configCount = configCount;
	}

	public IConfigurationService getConfigurationService() {
		return configurationService;
	}

	public void setConfigurationService(IConfigurationService configurationService) {
		this.configurationService = configurationService;
	}

	public IConfigAttrService getConfigAttrService() {
		return configAttrService;
	}

	public void setConfigAttrService(IConfigAttrService configAttrService) {
		this.configAttrService = configAttrService;
	}
	
	//=====================================================================
	
	public String configAdminMain(){
		configCount = configurationService.getConfigCount(0);
		return SUCCESS;
	}
	
	public String queryConfigList(){
		if(configurationVO==null){
			configurationVO = new ConfigurationVO();
		}
		allConfigurationList = configurationService.getConfigList();
		configurationList = configurationService.getConfigListByPage(configurationVO);
		return SUCCESS;
	}
	
	public String configSetPage(){
		configCount = configAttrService.getAttrCountByConfigid(configurationVO.getConfigid());
		configAttrList = configAttrService.getConfigAttrListByConfigGroup(configurationVO);
		configurationVO = configurationService.getConfigInfoByid(configurationVO.getConfigid());
		return SUCCESS;
	}
	
	public String addingAttr(){
		configAttrService.addConfigAttr(configAttrVO);
		if(configurationVO==null){
			configurationVO = new ConfigurationVO();
		}
		configurationVO.setConfigid(configAttrVO.getConfigid());
		return SUCCESS;
	}
	
	public String doDeleteAttr(){
		configAttrService.deleteConfigAttr(configAttrVO.getAttrid());
		if(configurationVO==null){
			configurationVO = new ConfigurationVO();
		}
		configurationVO.setConfigid(configAttrVO.getConfigid());
		return SUCCESS;
	}
	

}
